<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8" import="com.DB,java.sql.ResultSet"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>查找联系人</title>
</head>
<body>
<h1 align="center">查找联系人信息</h1>
<form method="post" action="">
请输入您要查询的联系人名称：
<input type=text name="search" id="search"> 
<input type=submit name="submit1" id="submit1">
<br/><br/><br/>
<table id = "order" style="width: 100%" border="1" >
<tr>
<td>名称：</td>
<td>性别：</td>
<td>家庭住址：</td>
<td>手机号码：</td>
<td>邮箱：</td>
<td>操作：</td>
</tr>
<!-- 设置编码方式 -->
<% request.setCharacterEncoding("UTF-8");%>
<% response.setContentType("text/html;charset=UTF-8"); %>	

<!-- 获取查询的用户名 -->
<% String cname = request.getParameter("search"); %>

<!-- 连接数据库，查询该用户的所有信息 -->
<% DB admin=new DB();	 %>
<% ResultSet myrs = admin.find(cname); %>

<!-- 将从数据库读出来的信息显示在页面中 -->
<% while(myrs.next())
{
	out.print("<tr>");
	out.print("<td>"+myrs.getString(2)+"</td>");
    out.print("<td>"+myrs.getString(3)+"</td>");
    out.print("<td>"+myrs.getString(4)+"</td>");
    out.print("<td>"+myrs.getString(5)+"</td>");
    out.print("<td>"+myrs.getString(6)+"</td>");  
    out.print("<td>"+"<input type=button name=\"button\" value=\"删除\" onclick=\"window.location.href=");
    out.print("'SearchServlet");
    out.print("?aID=");
    out.print(myrs.getString(1)+"'\">"); 
    out.print("</tr>");
} 
%>
</table>

<br/>
<br/>

</form>
</body>
</html>